package com.zhang.apiboss.controller;

import com.zhang.apiboss.service.CarService;
import com.zhang.apiboss.service.DriverUserService;
import com.zhang.internalcommon.dto.Car;
import com.zhang.internalcommon.dto.DriverUser;
import com.zhang.internalcommon.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类功能描述
 *
 * @author Kye
 * @date 2025-04-12
 */
@RestController
@Slf4j
public class DriverUserController {
	@Autowired
	private DriverUserService driverUserService;

	@Autowired
	private CarService carService;

	@PostMapping("/driver-user")
	public ResponseResult addDriver(@RequestBody DriverUser driverUser) {
		log.info(JSONObject.fromObject(driverUser).toString());
		return driverUserService.addDriverUser(driverUser);
	}

	@PutMapping("/driver-user")
	public ResponseResult updateDriver(@RequestBody DriverUser driverUser) {
		log.info(JSONObject.fromObject(driverUser).toString());
		return driverUserService.updateDriverUser(driverUser);
	}

	@PostMapping("/car")
	public ResponseResult addCar(@RequestBody Car car) {
		return carService.addCar(car);
	}
}
